package com.richardjaap.data;

import java.util.ArrayList;

public class Account {
	
	private int id;
	private String username;
	private String password;
	private double cashTotal;
	private boolean loggedOn = false;
	
	private final Player player = new Player(this);
	
	public Account(String username, String password){
		this.id = assignId();
		this.username = username;
		this.password = password;
		setCashTotal(2000);
	}
	
	public Player getPlayer(){
		return player;
	}
	
	private int assignId(){
		int lastId = 1;
		Lobby lobby = Lobby.getInstance();
		ArrayList<Player> p = lobby.getPlayers();
		if(p.size() != 0){
			Player player = p.get(p.size() - 1);
			lastId = player.getId();
		}
		return lastId;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isLoggedOn() {
		return loggedOn;
	}

	public void setLoggedOn(boolean loggedOn) {
		this.loggedOn = loggedOn;
	}

	public double getCashTotal() {
		return cashTotal;
	}

	public void setCashTotal(double cashTotal) {
		this.cashTotal = cashTotal;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

}
